package com.itheima.Jiuye13;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestMyCallable {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //线程开启后需要执行里面的Call方法
        MyCallable mc = new MyCallable();
        //MyCallable对象无法直接传给Thread，需要FtureTask作为中间人
        //FtureTask可以获取线程执行完之后返回的结果，
        FutureTask<String> ft = new FutureTask<>(mc);
        //创建线程对象
        Thread thread = new Thread(ft);
        //开启线程
        thread.start();
        //调用FtureTask的get方法获取到线程执行之后的返回值
        String s = ft.get();
        System.out.println(s);
    }
}
